#!/usr/bin/env python
# Query process returns the following information: tty, uid, pid, ppid and stime.

import commands, os, string

program = raw_input("Enter the name of your process to query:")

try:
    #excute the ps command and assign results to a list
    output = commands.getoutput(  "ps -ef|grep " + program)
    proginfo = string.split(  output)

    #display results
    print(   "\n\
            Terminal:\t\t", proginfo[  5]  , "\n\
            Owning User:\t\t\t", proginfo[  0]  , "\n\
            Process ID:\t\t", proginfo[  1]  , "\n\
            Parent Process ID:\t", proginfo[  2]  , "\n\
            System Time:\t\t", proginfo[  4])
except:
    print ( "There is a problem with the process u are querying.")
